package com.common.result;

/**
 * @author zyl
 * @Desc
 * @date 2023/7/20 10:03
 */
public enum ResultCode {
    // 2xx-成功
    SUCCESS(200, "操作成功"),

    // 4xx-客户端请求错误
    PARAM_ERROR(400, "输入参数不合法"),
    NO_LOGIN_AUTH(401, "请重新登录"),
    NO_OPERATION_AUTH(402, "缺少操作权限"),
    NO_DATA_AUTH(403, "缺少数据权限"),

    // 5xx-服务器错误
    SYSTEM_ERROR(500, "系统异常"),
    SYSTEM_BUSY_ERROR(501, "系统繁忙"),

    SYSTEM_EM_ERROR(601, "连接影像系统异常");

    private Integer code;
    private String msg;

    ResultCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ResultCode getEnum(Integer code) {
        for (ResultCode retEnum : ResultCode.values()) {
            if (retEnum.getCode().equals(code)) {
                return retEnum;
            }
        }
        return null;
    }

    public String getMsg() {
        return msg;
    }

    public Integer getCode() {
        return code;
    }
}
